-- card: 5437 from stack: in.6 -- bmap block id: 0 -- flags: 0000 -- background id: 3411 -- name: Type 2 XCMD -- part 1 (button) -- low flags: 80 -- high flags: A003 -- rect: left=287 top=66 right=89 bottom=403 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: "Change" Dialog ----- HyperTalk script ----- on mouseUp ShowDialog 2,4740,"Find What:","Change To:","Your string goes here." if the result is empty then put "You clicked the “Cancel” button." into bg fld "theResult" else put the result into temp if line 1 of temp is empty then put "String 1 was: empty" & return into bg fld "theResult" else put "String 1 was:" && line 1 of temp & return into bg fld "theResult" if line 2 of temp is empty then put "String 2 was: empty" after bg fld "theResult" else put "String 2 was:" && line 2 of temp after bg fld "theResult" end if end mouseUp -- part 2 (button) -- low flags: 80 -- high flags: A003 -- rect: left=232 top=98 right=121 bottom=456 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: "Change" Dialog with Checkbox ----- HyperTalk script ----- on mouseUp put TRUE into checked --checkbox initially checked ShowDialog 2,4744,"Find What:","Change To:", "Your string goes here.",checked if the result is empty then put "You clicked the “Cancel” button." into bg fld "theResult" else put the result into temp if item 1 of line 1 of temp = "TRUE" then put "Checked" into checked else put "Unchecked" into checked put "The checkbox was:" && checked & return into bg fld "theResult" if line 2 of temp is empty then put "String 1 was: empty" & return after bg fld "theResult" else put "String 1 was:" && line 2 of temp & return after bg fld "theResult" if line 3 of temp is empty then put "String 2 was: empty" after bg fld "theResult" else put "String 2 was:" && line 3 of temp after bg fld "theResult" end if end mouseUp -- part 3 (button) -- low flags: 80 -- high flags: A003 -- rect: left=294 top=130 right=153 bottom=393 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: "Ask" Dialog ----- HyperTalk script ----- on mouseUp ShowDialog 2,4741,"Type something in this box:","","This is the something!" if the result is empty then put "You clicked the “Cancel” button." into bg fld "theResult" else put the result into bg fld "theResult" end mouseUp -- part 4 (button) -- low flags: 80 -- high flags: A003 -- rect: left=258 top=162 right=185 bottom=425 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: "Ask" Dialog/no prompt ----- HyperTalk script ----- on mouseUp ShowDialog 2,4741,"Type something in this box:","","" if the result is empty then put "You clicked the “Cancel” button or left the field empty." into bg fld "theResult" else put the result into bg fld "theResult" end mouseUp -- part 6 (button) -- low flags: 80 -- high flags: A003 -- rect: left=256 top=194 right=217 bottom=427 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: Dialog with Many Fields ----- HyperTalk script ----- on mouseUp put "TRUE,FALSE,TRUE" into bools ShowDialog 2,4347,"Fill in your address information:","","",bools if the result is empty then exit mouseUp put the result into info put line 1 of info & return & line 2 of info && line 3 of info & return & line 4 of info & return & line 5 of info & "," && line 6 of info && line 7 of info into bg fld "theResult" end mouseUp -- part 7 (button) -- low flags: 80 -- high flags: 0000 -- rect: left=11 top=4 right=64 bottom=78 -- title width / last selected line: 0 -- icon id / first selected line: 529 / 529 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: -- part 8 (button) -- low flags: 00 -- high flags: 0000 -- rect: left=11 top=4 right=64 bottom=78 -- title width / last selected line: 0 -- icon id / first selected line: 529 / 529 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: SD -- part contents for background part 21 ----- text ----- ShowDialog XCMD Type 2 -- part contents for background part 30 ----- text ----- 14 -- part contents for background part 18 ----- text ----- The HyperCard "ask" dialog is functional for providing information to the user and then retrieving information from the user but is not a pretty sight. (Where's the icon?) Additionally, it would be handy to have an "ask" dialog that could return more than one string, for, say, a search and replace dialog box, à la any word processor, or a data entry dialog, and a number of check boxes so you could perform some BOOLEAN operations. ShowDialog XCMD Type 2 provides a mechanism for the display of such interactive dialog boxes.            ••••••••••••••••• If you've been using versions of ShowDialog older than 1.6, please note that one parameter for Type 2 has been removed. In addition, the result is now RETURN-delimited, instead of comma-delimited. ShowDialog Type 2 can also now have AS MANY Editable Text fields and check boxes as you desire.            ••••••••••••••••• -- part contents for background part 15 ----- text ----- ShowDialog Type 2 parameters are: ShowDialog 2,,,, [,],[,] where 2 is the type of the external; is the resource ID of the DLOG template; consists of the dialog's first text string; consists of the dialog's second text string (if you want one); is a default text string to appear in a text entry field; The last three parameters are OPTIONAL. They are: specifies whether your check boxes (if you have any) are initially checked. This is a comma-delimited list ("TRUE,FALSE,TRUE,TRUE"); and are used to set the top,left coordinates for placing the dialog. If these two parameters are omitted, the dialog will be centered within the card window. -- part contents for background part 17 ----- text ----- Creating the resources for ShowDialog XCMD Type 2: The requirements for creating DLOG templates for Type 2 of ShowDialog XCMD with ResEdit are: The visible and goAwayFlag boxes must be unchecked, and the DLOG and associated DITL resources should be made purgeable. You MUST have a default button and it MUST be DITL item #1. This is because the first item in the item list is always assumed to be the default button. The Macintosh Toolbox will interpret a press of the Return or Enter key as equivalent to a mouse click in the default button. In your DITL template, your field (of type Static Text) that will contain the first prompt string must contain the placeholder "^0" (don't use the quotes; and that's a zero) and the field that will contain the second text string must contain the placeholder "^1". If you only want to have one field of static text in your dialog, simply omit the second static text field in the template and pass an empty string in the parameter. The field (of type Editable Text) that will contain the default entry string MUST be DITL item #3. CHECK BOXES: Your check boxes can be ANY DITL item#. You can have the check boxes initially hilited when the dialog is displayed by passing TRUE (for each check box you want hilited) in the parameter. In other words, if you have 3 check boxes in your dialog, passing "TRUE,FALSE,TRUE" will hilite the first and third check boxes. If you pass FEWER items in this parameter than there are check boxes, the remaining check boxes will be unhilited. If you pass MORE items in this parameter than there are check boxes, the remaining items will be ignored. Follow this outline when constructing the DITL resource: item #1: OK button (the default) item #2: Cancel button item #3: Editable Text field (to contain default entry        string) remaining items: Check boxes, additional fields of Editable Text, Static Text fields, icons, and PICT's. The ONLY items that are to be ENABLED are buttons, your check boxes (if you have any), and Editable Text fields. Decide the window type for the dialog: What you enter into the procID field in the DLOG template will determine how the dialog box looks and whether a window titlebar is displayed. The types that you can choose from are: 0: standard window with titlebar 1: standard dialog or alert box (no titlebar) 2: dialog or alert box with a plain border (no    titlebar) 3: dialog or alert box with "shadow" (no titlebar) 16: accessory window with titlebar (like the    calculator DA) Please note that having modal dialog boxes with window titlebars is a deviation from Macintosh User Interface guidelines, so you might want to refrain from using these. The result consists of a return-delimited list. If you have only one Editable Text field in your dialog then "the result" will contain the contents of that field. If you have two or more Editable Text fields, "the result" will contain the contents of the fields in a return-delimited list. If you have check boxes in your dialog, the first line of the result will be a comma-delimited list reflecting the state of the check boxes at the time the dialog was dismissed. There will be as many items in the list as there were check boxes in your dialog. The items will be TRUE for hilited check boxes and FALSE for unhilited ones. If the user clicks the Cancel button "the result" will be empty.